package com.qububu.emporium.shoppingCart;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.springframework.context.ApplicationContext;

import com.qububu.emporium.shoppingCart.service.ShoppingCartService;
import com.qububu.systemBase.ApplicationContextHandler;

/**
 * @功能 session监听, session过期前数据获取
 * */
public class ShoppingCartSessionListener implements HttpSessionListener {

	private ShoppingCartService shoppingCartService;
	
	private void setShoppingCartService() {
		ApplicationContext applicationContext = ApplicationContextHandler.getApplicationContext();
		this.shoppingCartService = (ShoppingCartService) applicationContext.getBean("shoppingCartService");
	}
	
	public void sessionCreated(HttpSessionEvent sessionEvent) {
		
	}

	public void sessionDestroyed(HttpSessionEvent sessionEvent) {
		
//		System.out.println("\n----"+System.currentTimeMillis()+"-----ShoppingCartSessionListener 中监听到session被----销毁-------\n");
		
		setShoppingCartService();
	}
	
}
